{% extends 'cms/base/dashboard_base.html' %}

{% block title %}
    {% if item_data %}
        Navbar Item Edit
    {% else %}
        Navbar Item Publish
    {% endif %}
{% endblock %}

{% block main %}
    <section class="content">
        <div class="container-fluid">
            <div class="row d-flex justify-content-center pt-4">
                <div class="col-sm-10">
                    <div class="card card-primary">
                        <div class="card-header">
                            {% if item_data %}
                                <h3 class="card-title">Navbar Item Edit</h3>
                            {% else %}
                                <h3 class="card-title">Navbar Item Publish</h3>
                            {% endif %}
                        </div>
                        <!-- form start -->
                        <form class="form-horizontal" action="{% url 'cms:navitem_add' %}" method="post">
                            {% csrf_token %}
                            {% if item_data %}
                                <input type="text" class="form-control" id="pk" name="pk" value="{{ item_data.id }}" hidden>
                            {% endif %}
                            <div class="card-body">
                                <div class="form-group row ">
                                    <label for="name" class="col-form-label col-sm-2 text-center">Name</label>
                                    <div class="col-sm-10">
                                        {% if item_data %}
                                            <input type="text" class="form-control" id="name" name="name" value="{{ item_data.name }}">
                                        {% else %}
                                            <input type="text" class="form-control" id="name" name="name">
                                        {% endif %}
                                    </div>
                                </div>

                                <div class="form-group row ">
                                    <label for="show_name" class="col-form-label col-sm-2 text-center">Show Name</label>
                                    <div class="col-sm-10">
                                        {% if item_data %}
                                            <input type="text" class="form-control" id="show_name" name="show_name" value="{{ item_data.show_name }}">
                                        {% else %}
                                            <input type="text" class="form-control" id="show_name" name="show_name">
                                        {% endif %}
                                    </div>
                                </div>

                                <div class="form-group row ">
                                    <label for="url_path" class="col-form-label col-sm-2 text-center">URL Path</label>
                                    <div class="col-sm-10">
                                        {% if item_data %}
                                            <input type="text" class="form-control" id="url_path" name="url_path" value="{{ item_data.url_path }}">
                                        {% else %}
                                            <input type="text" class="form-control" id="url_path" name="url_path">
                                        {% endif %}
                                    </div>
                                </div>


                                <div class="form-group row">
                                    <label for="status" class="col-form-label col-sm-2 text-center">Status</label>
                                    <div class="col-sm-10">
                                        <select name="status" id="status" class="custom-select ">
                                            {% if item_data %}
                                                {% for item in list_data_status %}
                                                    <option value="{{ item.0 }}" {% if item.0 == item_data.status %} selected {% endif %}>{{ item.1 }}</option>
                                                {% endfor %}
                                            {% else %}
                                                {% for item in list_data_status %}
                                                    <option value="{{ item.0 }}">{{ item.1 }}</option>
                                                {% endfor %}
                                            {% endif %}
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label for="show_page" class="col-form-label col-sm-2 text-center">Show Page</label>
                                    <div class="col-sm-10">
                                        <select name="show_page" id="show_page" class="custom-select ">
                                            {% if item_data %}
                                                {% for item in list_data_show_page %}
                                                    <option value="{{ item.0 }}" {% if item.0 == item_data.show_page %} selected {% endif %}>{{ item.1 }}</option>
                                                {% endfor %}
                                            {% else %}
                                                {% for item in list_data_show_page %}
                                                    <option value="{{ item.0 }}">{{ item.1 }}</option>
                                                {% endfor %}
                                            {% endif %}
                                        </select>
                                    </div>
                                </div>

                            </div>
                            <!-- /.card-body -->
                            <div class="card-footer">
                                {% if item_data %}
                                    <button type="submit" class="btn btn-info" name="modify">Submit</button>
                                    <button type="submit" class="btn btn-danger float-right" name="cancel">Cancel</button>
                                {% else %}
                                    <button type="submit" class="btn btn-info" name="submit">Submit</button>
                                    <button type="submit" class="btn btn-danger float-right" name="back">Back</button>
                                {% endif %}
                            </div>
                            <!-- /.card-footer -->
                        </form>
                    </div>
                </div>
            </div>

        </div>
    </section>
{% endblock %}